package fr.utbm.gi.vi51.project.agent.frustum;

import javax.vecmath.Point2d;
import javax.vecmath.Vector2d;

public class Frustum {

	private int sightRadius;
	private int attackRadius;

	public Frustum(int sightRadius, int attackRadius) {
		this.attackRadius = attackRadius;
		this.sightRadius = sightRadius;
	}

	public boolean isVisible(Point2d selfPosition, Point2d objectPosition) {
		if (new Vector2d(objectPosition.getX() - selfPosition.getX(), objectPosition.getY() - selfPosition.getY())
				.length() < this.sightRadius) {
			return true;
		}
		return false;
	}

	/**
	 * This shouldn't be called a Frustum as it has nothing to do with the unit's sight. It was put here for
	 * simplification purpose.
	 * 
	 * @param objectPosition
	 * @return
	 */
	public boolean isAttackable(Point2d selfPosition, Point2d objectPosition) {
		if (new Vector2d(objectPosition.getX() - selfPosition.getX(), objectPosition.getY() - selfPosition.getY())
				.length() < this.attackRadius) {
			return true;
		}
		return false;
	}

}
